Israel’s Battle with COVID-19

rm(list=ls())
source("../DATA/movavg.R")
db <- dbConnect(SQLite(), dbname="../COVID-19-DB/OURWORLD.sqlite3")
df <- dbGetQuery(db,"select * from JHU")
df <- subset(df,location =="Israel")
df$date <- as.Date(df$date)
sum(df$new_cases,na.rm=TRUE)
## [1] 558249
sum(df$new_deaths,na.rm=TRUE)
## [1] 4044
US <- subset(df,date >="2020-02-21" & new_cases >=1)
US <- US[order(US$date,decreasing = TRUE),]
US$MA14 <- movingAverage(US$new_cases,14)
US$MAD <- movingAverage(US$new_deaths,14)
US$Rate <- US$new_deaths/US$new_cases

Israel COVID19 Mortality Rate

A <- subset(US,date >="2020-07-01")
ggplot(A) + # geom_line(aes(x=date,y=Rate)) +
  scale_y_continuous(labels = scales::percent) +
  labs(title="Israel COVID19 Mortality Rate ",x="Date date",y="Mortality Rate") +
  geom_hline(yintercept = mean(A$Rate),col="red") +
  geom_smooth(aes(x=date,y=Rate,col="Loess"),span=0.15) +
  scale_alpha_date()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

Plot of Daily new_cases and new_deaths

plot1 <-ggplot(US) +  # geom_line(aes(x=date,y=new_cases,col="Daily new_cases")) +
  labs(title="COVID-19 new_cases by Date") +
    geom_smooth(aes(x=date,y=new_cases,col="Loess"),span=0.15) +
   scale_alpha_date()

plot2<-ggplot(US) + # geom_line(aes(x=date,y=new_deaths,col="Daily new_deaths")) +
  labs(title="COVID-19 new_deaths by Date") + ylim(0,100) +
  geom_smooth(aes(x=date,y=new_deaths,col="Loess"), span=0.15) +
   scale_alpha_date()
  

ggplotly(plot1)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
ggplotly(plot2)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
## Warning: Removed 21 rows containing non-finite values (stat_smooth).
USA <- subset(US,date >="2020-06-01")
ggplot(USA) + # geom_line(aes(x=date,y=new_cases,col="Daily new_cases")) +
  labs(title="COVID-19 new_cases by Date since Jun. 1, 2020") +
  geom_smooth(aes(x=date,y=new_cases,col="Loess"),span=0.25) +
   scale_alpha_date()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

ggplot(USA) + # geom_line(aes(x=date,y=new_deaths,col="Daily new_deaths")) +
  labs(title="COVID-19 new_deaths by Date (since Jun. 1, 2020)") + ylim(0,70) +
  geom_smooth(aes(x=date,y=new_deaths,col="Loess"),span=0.25) +
   scale_alpha_date()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

Non-Moving Average By Week and By Month

US$Monthly <- as.Date(cut(US$date,
  breaks = "month"))
US$Weekly <- as.Date(cut(US$date,
  breaks = "week",
  start.on.monday = FALSE))
Weekly_new_cases <- aggregate(new_cases~Weekly,US,FUN=sum)
Weekly_new_deaths <- aggregate(new_deaths~Weekly,US,FUN=sum)
Weekly_new_cases$DRate <- Weekly_new_deaths$new_deaths/Weekly_new_cases$new_cases
## Warning in Weekly_new_deaths$new_deaths/Weekly_new_cases$new_cases: longer
## object length is not a multiple of shorter object length
Weekly_new_cases$LivedSaved <- Weekly_new_cases$new_cases * (max(Weekly_new_cases$DRate) - Weekly_new_cases$DRate) 
ggplot(Weekly_new_cases) + geom_col(aes(x=Weekly,y=new_cases)) + 
  labs(title="Weekly new_cases",x="Date date", y="Weekly new_cases") +
   scale_alpha_date()

ggplot(Weekly_new_deaths) + geom_col(aes(x=Weekly,y=new_deaths)) + 
  labs(title="Weekly new_deaths",x="Date date", y="Weekly new_deaths") +
   ylim(0,400) +  scale_alpha_date()

Monthly new_cases and new_deaths

Monthly_new_cases <- aggregate(new_cases~Monthly,US,FUN=sum)
Monthly_new_deaths <- aggregate(new_deaths~Monthly,US,FUN=sum)
Monthly_new_cases$DRate <- Monthly_new_deaths$new_deaths/Monthly_new_cases$new_cases
## Warning in Monthly_new_deaths$new_deaths/Monthly_new_cases$new_cases: longer
## object length is not a multiple of shorter object length
Monthly_new_cases$LivedSaved <- Monthly_new_cases$new_cases * (max(Monthly_new_cases$DRate) - Monthly_new_cases$DRate) * 100
ggplot(Monthly_new_cases) + geom_col(aes(x=Monthly,y=new_cases)) +
  labs(title="Monthly new_cases") +
  scale_y_continuous(labels=scales::comma) +
   scale_alpha_date()

ggplot(Monthly_new_deaths) + geom_col(aes(x=Monthly,y=new_deaths)) +
  labs(title="Monthly new_deaths") +
   scale_alpha_date()